/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.chapter5.designpatters.behavioralpattern.momentopattern;

/**
 *
 * @author Sakhe
 */
public class DietInfo {
   
    String personName;
    int dayNumber;
    int weight;
    public DietInfo(String personName, int dayNumber , int weight){
    this.personName = personName;
    this.dayNumber = dayNumber;
    this.weight = weight;
}
    public String toString(){
    return "Name : " +personName+ " , day number : " +dayNumber+ " , weight : " +weight;
}
    public void setDayNumberAndWeight(int dayNumber , int weight){
    this.dayNumber = dayNumber;
    this.weight = weight;
    }
    public Memento save(){
    return new Memento(personName , dayNumber , weight);
    }
    public void restore(Object objMemento){
    Memento memento = (Memento) objMemento;
    personName = memento.mementoPersonName;
    dayNumber = memento.mementoDayNumber;
    weight = memento.mementoWeight;
    }
    // memento .. obj e c t that s t o r e s the saved s t a t e o f the o r i g i n a t o r
    private class Memento{
    String mementoPersonName;
    int mementoDayNumber;
    int mementoWeight;
    public Memento(String personName ,int dayNumber ,int weight){
    mementoPersonName = personName;
    mementoDayNumber = dayNumber;
    mementoWeight = weight;
    }
    }
}
